<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<head>
<link type="text/css" href="/lib/chart_bars/css/jqbar.css" rel="stylesheet" />
<script src="/js/jquery.js" type="text/javascript"></script>
<script src="/lib/chart_bars/js/jqbar.js" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(function() {

	// chart bars 생성
	<c:forEach var="item" items="${ listMap }" varStatus="status">
	
		$('#bar-' + '${status.count}').jqbar({
			//label : '',
			value : '${item.PERC}',
			barColor : '#D64747'
		});
	</c:forEach>
	});
	
	function downloadExcel(site, tableName, days, title)
	{
		var form = document.forms["excelDownloadFrm"];
		
		var type = "";
		if(tableName == "nm_access")
		{
			type = "visitor";
		}
		else
		{
			type = "pageview";
		}
		
		form.site.value = site;
		form.tableName.value = tableName;
		form.input_date.value = days;
		form.title.value = type + "_" + title + "_" + days;
		form.submit();
		
		return true;
	}
</script>
</head>
<div class="ac t20">
</div>
<div class="mt_20 ar">
	<span class="button btnProc01">
		<a href="#" onclick="downloadExcel('${commandMap.site}', '${commandMap.tableName}', '${commandMap.input_date}', 'year')">통계 다운로드</a>
	</span>
</div>
<table cellpadding="0" cellspacing="0" border="0" class="tbl_type01">
	<colgroup>
		<col width="100px" />
		<col width="120px" />
		<col />
	</colgroup>
	<thead>
		<tr>
			<th>날짜</th>
			<th>
			<c:if test="${commandMap.tableName eq 'nm_access'}">
				방문자수
			</c:if>
			<c:if test="${commandMap.tableName eq 'nm_pageview'}">
				페이지뷰
			</c:if>
			</th>
			<th>그래프 (%)</th>
		</tr>
	</thead>
	<tbody>
		<c:forEach var="item" items="${ listMap }" varStatus="status">
		<tr>
			<td>${item.INPUT_DATE}</td>
			<td><fmt:formatNumber value="${item.TOTAL}" type="number" /> (${item.PREC}명)</td>
			<td class="al" ><div id="bar-${status.count}"></div></td>
		</tr>
		</c:forEach>
	</tbody>
</table>					